package com.an.vhr.controller.salary;

import com.an.vhr.bean.RespBean;
import com.an.vhr.bean.RespPageBean;
import com.an.vhr.bean.Salary;
import com.an.vhr.service.EmpSalaryService;
import com.an.vhr.service.EmployeeService;
import com.an.vhr.service.SalaryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: an1089
 **/
@RestController
@RequestMapping("/salary/sobcfg")
public class SobConfigController {
    @Resource
    EmployeeService employeeService;
    @Resource
    SalaryService salaryService;
    @Resource
    EmpSalaryService empSalaryService;

    @GetMapping("/")
    public RespPageBean getEmployeeWithSalaryPage(@RequestParam(defaultValue = "1") Integer page,
                                              @RequestParam(defaultValue = "10") Integer size){
        return employeeService.getEmployeeWithSalaryPage(page, size);
    }

    @GetMapping("/salaries")
    public List<Salary> getAllSalaries(){
        return salaryService.getAllSalary();
    }

    @PutMapping("/")
    public RespBean updateEmpSalary(Integer eid, Integer sid){
        Integer integer = empSalaryService.updateEmpSalary(eid, sid);
        if(integer == 1 || integer == 2){
            return RespBean.ok("更新成功");
        }
        return RespBean.ok("更新失败");
    }
}
